package com.singzi.leetcode.N400;

public class T0383 {

    public static void main(String[] args) {
        String s1 = "aababgggggggggggggggggggffffffffffffffffffffffff";
        String s2 = "aaaaafgfgffffbfffffffffffffffffffffffffffffffffffffffffggggggggggggggggggggggggggggggggggggggggggb";
        Solution0383 solution0383 = new Solution0383();
        System.out.println(solution0383.canConstruct(s1, s2));
    }
}
class Solution0383 {
    public boolean canConstruct(String ransomNote, String magazine) {

        boolean flag = true;
        int[] ransom = new int[26];
        for (int i = 0; i < magazine.length(); i++) {

            ransom[magazine.charAt(i)-97]++;

        }
        for (int i = 0; i < ransomNote.length(); i++) {
            ransom[ransomNote.charAt(i)-97]--;
            if(ransom[ransomNote.charAt(i)-97] < 0){
                flag = false;
            }
        }


        return flag;

    }
}